package com.visitor;

import com.visitor.hidein.Element;
import com.visitor.showout.Visitor;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @Author: zishu
 * @Description: 为访问者提供具体实现的类
 * @Date: 2022/2/4 14:36
 **/
public class ObjectAccept {

    private List<Element> list = new ArrayList<>();

    public void accept(Visitor visitor) {
        Iterator<Element> iterator = list.iterator();
        while ( iterator.hasNext() )
            ((Element) iterator.next()).accept(visitor);
    }

    public void add(Element element) {
        list.add(element);
    }
    public void remove(Element element) {
        list.remove(element);
    }

}
